package cn.tiansu.eway.datafile.manager;

import java.text.ParseException;
import java.util.Date;
import java.util.Set;

import org.apache.log4j.Logger;
import org.quartz.SchedulerException;

import cn.tiansu.eway.common.utils.Log4jInitializer;
import cn.tiansu.eway.common.utils.PropertyConfigurator;
import cn.tiansu.eway.common.utils.QuartzManager;
import cn.tiansu.eway.kafka.ijava.TSMessageQueue;
import cn.tiansu.eway.kylinengine.service.KYLINEngineService;

/**
 * 数据服务生成入口
 * 
 * @Title: FileManager.java
 * @Description: TODO
 * @author: 吴鹏
 * @date: 2015年9月14日
 * 
 *
 */
public class FileManager
{
	private static String modelName = "fileEngine_kylin";

	/**
	 * 二次采样
	 */
	private static String cmd = "PubReSample";

	/**
	 * 二次修复
	 */
	private static String fix_cmd = "PubFixSampleInfo";

	private static final Logger log = Logger.getLogger(FileManager.class);

	public static void main(String[] args)
	{
		Log4jInitializer.init("");

		log.info("===begin FileManager====");

		// 注册模块信息
		FileListener l = FileListener.getInstance();
		TSMessageQueue teQueue = new TSMessageQueue(l);
		teQueue.open(modelName, cmd);
		String[] arr =
		{ cmd, fix_cmd };
		teQueue.subscibeMsg(arr);
		teQueue.start();

		RefreshCubeJob job = new RefreshCubeJob();
		MakeDataFileJob mdJob = new MakeDataFileJob();
		try
		{
			// 每天19点10分执行
			// "0 10 19 * * ?"
			String jobTime = PropertyConfigurator.getInstance(null,
					"config.properties").getParameter("jobTime");
			QuartzManager.addJob("RefreshCubeJob", job, jobTime);

			String makeDataJobTime = PropertyConfigurator.getInstance(null,
					"config.properties").getParameter("makeDataJobTime");
			QuartzManager.addJob("MakeDataFileJob", mdJob, makeDataJobTime);

		} catch (SchedulerException e1)
		{
			log.error("", e1);
		} catch (ParseException e1)
		{
			log.error("", e1);
		}
	}
}
